package com.aso114.project.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;

import com.aso114.project.bean.CourseBean;
import com.aso114.project.mvp.activity.fragment.AdministrarAptitudeTestFragment;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by hp on 2017/10/29.
 */
/*
在做一个技术开源、内容社区，感兴趣的小伙伴加入吧
    Android、Java、c#等技术交流群：161154103
    创业想法的小伙伴更是欢迎
     */

public class TabFragmentStatePagerAdapter extends FragmentStatePagerAdapter {
    private List<Fragment> fragmentList;
    private ArrayList<CourseBean> courseBeanList;
    public TabFragmentStatePagerAdapter(FragmentManager fm) {
        super(fm);
    }
    public void setFragments(List<Fragment> fragments) {
        this.fragmentList = fragments;
    }
    public void setCategoriesBeans(ArrayList<CourseBean> coursBeans) {
        this.courseBeanList = coursBeans;
    }
    @Override
    public Fragment getItem(int position) {
        return fragmentList.get(position);
    }

    @Override
    public int getCount() {
        return courseBeanList.size();
    }
    //给TabLayout赋值
    @Override
    public CharSequence getPageTitle(int position) {
        return courseBeanList.get(position%courseBeanList.size()).getTitle();
    }
}
